var mysql  = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '123456',
  database : 'web'
});
// let sql = 'SELECT * FROM hg_users'
// connection.query(sql,  (error, results)=> {
//     if(error){
//       console.log('error',error)
//     }else{
//       console.log('results',results)
//     }
//   });
function request(sql){
    return new Promise((resolve,reject)=>{
      connection.query(sql,  (error, results)=> {
          if(error){
            reject(error)
          }else{
            resolve(results)
          }
      });
    })
}
// 暴露出去
module.exports ={
  connection,
  request
}